package cn.edu.scau.cmi.wuzhenzhou.factory;

import java.net.URL;
import java.util.ResourceBundle;

import cn.edu.scau.cmi.wuzhenzhou.factory.BeefMeatFactory;
import cn.edu.scau.cmi.wuzhenzhou.factory.ChickenMeatFactory;
import cn.edu.scau.cmi.wuzhenzhou.factory.MeatFactory;
import cn.edu.scau.cmi.wuzhenzhou.factory.PorkMeatFactory;
import cn.edu.scau.cmi.wuzhenzhou.simpleFactoryMethod.domain.Meat;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class MyController implements Initializable{
	@FXML
	private TextField field;
	@FXML
	private Label label;
	@FXML
	private TextArea view;
	
	MeatFactory meatFactory = null;
	
	
	@Override
	public void initialize(URL location, ResourceBundle resources) {
		// TODO Auto-generated method stub
		
	}
	
	public void estimate(ActionEvent event) {
		if(!field.getText().equals("beef")&&
		   !field.getText().equals("pork")&&
		   !field.getText().equals("chicken")) {
			label.setText("sorry, your input is not correct");
		} else {
			label.setText("your input is correct");
			switch (field.getText()) {
			case "beef" : meatFactory = new BeefMeatFactory();break;
			case "pork" : meatFactory = new PorkMeatFactory();break;
			case "chicken" : meatFactory = new ChickenMeatFactory();break;
			}
			view.setText(meatFactory.getMeat().cook());
		}
	}
	
}

